package com.damei.qmui_test_demo.activity.home;

import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toolbar;

import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.damei.qmui_test_demo.R;
import com.damei.qmui_test_demo.activity.AssetsActivity;
import com.damei.qmui_test_demo.base.BaseActivity;
import com.damei.qmui_test_demo.httpService.HttpManager;
import com.damei.qmui_test_demo.httpService.HttpStringResponseHandler;
import com.damei.qmui_test_demo.model.MeiZiResponse;
import com.damei.qmui_test_demo.model.PersonModel;
import com.damei.qmui_test_demo.service.NavigationCallBack;
import com.damei.qmui_test_demo.view.AssetsListAdapter;
import com.damei.qmui_test_demo.view.DataListAdapter;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
import com.xuexiang.xui.widget.actionbar.TitleBar;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class DataListActivity extends BaseActivity {

    @BindView(R.id.refresh_layout)
    RefreshLayout refreshLayout;

    @BindView(R.id.data_list_view)
    RecyclerView recyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_data_list);
        ButterKnife.bind(this);

        TitleBar titleBar = setNavigationAction("开单总览", Color.parseColor("#FFDEDA"), null);
        titleBar.setBackImageResource(R.drawable.left_icon);
        titleBar.setTitleColor(Color.parseColor("#000000"));

        List<String> list = new ArrayList<String>();
        list.add("111");
        list.add("111");
        list.add("111");
        list.add("111");
        list.add("111");
        list.add("111");
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setAdapter(new AssetsListAdapter(this, list));

        refreshOrLoadMoreAction();
    }

    /**
     * 刷新加载事件
     */
    private void refreshOrLoadMoreAction() {
        refreshLayout.setPrimaryColors(Color.parseColor("#FFDEDA"));
        refreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                refreshlayout.finishRefresh(2000/*,false*/);
            }
        });
        refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                refreshLayout.finishLoadMore(2000);
            }
        });
    }
}

